//
//  StorageUtil.m
//  BallLight
//
//  Created by jnl on 2017/11/18.
//  Copyright © 2017年 qin. All rights reserved.
//

#import "StorageUtil.h"

@implementation StorageUtil


#pragma mark - 获取当前家庭的ID
+(NSString *)getFamilyId
{
  return  [StorageUtil getValueWithKey:@"curr_family_id"];
}

#pragma mark - 保存当前家庭的ID
+(void)saveFamilyId:(NSString *)familyId
{
    return  [StorageUtil saveValueWithKey:@"curr_family_id" value:familyId];
}

#pragma mark - 保存key-value
+(void)saveValueWithKey:(NSString *)key  value:(id) value
{
    [[NSUserDefaults standardUserDefaults] setObject:value forKey:key];
}

#pragma mark - 根据key获取value
+(id)getValueWithKey:(NSString *)key
{
    return  [[NSUserDefaults standardUserDefaults] objectForKey:key];
}


#pragma mark - 保存key-bool
+(void)saveBoolWithKey:(NSString *)key  value:(BOOL) value
{
    [[NSUserDefaults standardUserDefaults] setBool:value forKey:key];
}

#pragma mark - 根据key获取bool value
+(BOOL)getBoolWithKey:(NSString *)key
{
    return  [[NSUserDefaults standardUserDefaults] boolForKey:key];
}

#pragma mark - 获取当前语言的key
+(NSString *)getLanguageKey
{
    NSString * language_key=[StorageUtil getValueWithKey:@"language_key"];
    if(!language_key){
//        language_key=@"zh-CN";
        language_key=@"普通话";
    }
    return language_key;
}

#pragma mark - 保存当前语言的key
+(void)saveLanguageKey:(NSString *)key
{
    [StorageUtil saveValueWithKey:@"language_key" value:key];
}


#pragma mark - 获取是否初始化
+(BOOL)getFirstInit{
    return [StorageUtil getBoolWithKey:@"First_Init"];
}
#pragma mark - 标记初始化过
+(void)saveFirstInit:(BOOL) value{
     [StorageUtil saveBoolWithKey:@"First_Init" value:value];
}

#pragma mark - 获取语音开关
+(BOOL)getSpeechSwitch
{
    return [StorageUtil getBoolWithKey:@"is_close_speech"];
}
#pragma mark - 保存当前语音是否开关
+(void)saveSpeechSwitch:(BOOL) status
{
    [StorageUtil saveBoolWithKey:@"is_close_speech" value:status];
}

#pragma mark - 获取网络状态
+(BOOL)getNetStatus
{
    return [StorageUtil getBoolWithKey:@"network_enable"];
}
#pragma mark - 保存当前网络状态
+(void)saveNetStatus:(BOOL) status
{
    [StorageUtil saveBoolWithKey:@"network_enable" value:status];
}

@end
